<?php

namespace App\Admin\Controller\Base;

use App\Common\Provider\Uploader\UploaderInterface;
use App\Common\Util\Response;
use App\Common\Util\TP;
use Psr\Http\Message\ResponseInterface;
use think\annotation\route\Group;
use think\annotation\route\Route;

/**
 * 公共
 *
 * Class CommonController
 */
#[Group(name: 'common')]
class CommonController
{
    /**
     * 上传
     *
     * @return \think\Response
     */
    public function upload(): \think\Response
    {
        /** @var UploaderInterface $uploader */
        $uploader = app(UploaderInterface::class);
        $data     = $uploader->upload(TP::request()->file('file'));

        return Response::json()->success($data->fileFullPath);
    }

    /**
     * @return \think\Response
     */
    public function froalaUpload(): \think\Response
    {
//        return Response::json()->success(['link' => 'path']);

        return $this->upload();
    }
}